import platform
from ctypes import *
import matplotlib.pyplot as plt

if platform.system() == 'Windows':
    libc = cdll.LoadLibrary('missile.dll')
elif platform.system() == 'Linux':
    libc = cdll.LoadLibrary('missile.so')

# 指定 C 函数的参数类型
libc.AerocraftInit.argtypes = [c_double, c_double, c_double, c_double]
# 指定 C 函数的返回值类型
libc.getAerocraftX.restype = c_double
libc.getAerocraftY.restype = c_double
libc.getAerocraftZ.restype = c_double

libc.getMissileX.restype = c_double
libc.getMissileY.restype = c_double
libc.getMissileZ.restype = c_double

x = []
y = []
z = []
m_x = []
m_y = []
m_z = []
libc.AerocraftInit(-3000, 3000, 15000, 800)  # x, y ,h , s
for i in range(800):
    libc.control()
    x.append(libc.getAerocraftX())
    y.append(libc.getAerocraftY())
    z.append(libc.getAerocraftZ())
    m_x.append(libc.getMissileX())
    m_y.append(libc.getMissileY())
    m_z.append(libc.getMissileZ())
libc.showinfo()
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.scatter3D(x, y, z, color="red", s=1)
ax.scatter3D(m_x, m_y, m_z, color="green", s=1)
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
